﻿#include "GameCore_Thread.h"

//#include "_Global/Sqlite/Sqlite.h"
//#include "_Global/Socket/ClientSocket.h"

#include "../_Global/GlobalClass.h"


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


GameCore_Thread::GameCore_Thread(QObject *parent)
    :GameClientThreadModel(parent)
{
    /*
    m_PaiDui = new _Pai[GAME_MAX_NUM_PAI];

    m_hashGameMessage[_Pai::Value_Sha].append(_T("请选择一名角色，作为%1的目标"));
    m_hashGameMessage[_Pai::Value_Sha].append(_T("请出一张%1"));
    m_hashGameMessage[_Pai::Value_Shan].append(_T("请出一张%1"));
    m_hashGameMessage[_Pai::Value_Shan].append(_T("！%1不出%2！"));
    */
    m_eGameType = Game_Type_NULL;
    m_nGameMessageDelay = 0;
    m_nPlayerCount = 0;
}

GameCore_Thread::~GameCore_Thread()
{
    /*
    if(m_PaiDui != nullptr)
    {
        delete[] m_PaiDui;
        m_PaiDui = nullptr;
    }*/
}

int GameCore_Thread::InitOnce()
{
    return GameClientThreadModel::InitOnce();
}

int GameCore_Thread::InitOnceInThread()
{
    return GameClientThreadModel::InitOnceInThread();
}

int GameCore_Thread::GameInit(int sr)
{
    m_GameFightLogical.init();
    m_GameFightLogical.m_listFightPets.append(m_GameNormalLogical.m_listPets.at(0));
    m_GameFightLogical.createEnemyPets();

    return GameClientThreadModel::GameInit(sr);
}

GameClientModel::_GameStatus GameCore_Thread::GameLoop()
{
    for(;;) //游戏主循环
    {
        WaitForUserAction();

        setGameStatus(m_GameFightLogical.HuiHe(m_GameFightLogical.m_UserChoice));

        if(gameStatus() != GameClientModel::Game_Status_Continue)
            break;
    }

    return gameStatus();
}

GameClientModel::_GameStatus GameCore_Thread::CheckGameOver()
{
    if(GameClientThreadModel::CheckGameOver() != GameClientModel::Game_Status_Continue)
    {
        return gameStatus();
    }

    return m_GameFightLogical.CheckGameOver();
}

int GameCore_Thread::GameOver()
{
    return GameClientThreadModel::GameOver();
}


void GameCore_Thread::GameTypeInit()
{

    switch (this->m_eGameType) {
    case Game_Type_1:
        break;
    default:
        break;
    }

}
